﻿// JavaScript Document
//服务器配置信息
var SGA = {   
    webroot:'http://192.168.1.110:8080/mjsys/'
   // webroot:'http://192.168.1.104:8080/mjsys/'
};

var requestParam = function(obj, objname) {
    var query = '', name, value, fullSubName, subName, subValue, innerObj, i;

    for(name in obj) {
        value = obj[name];

        if(value instanceof Array) {
            for(i=0; i<value.length; ++i) {
                subValue = value[i];
                if(objname != undefined) fullSubName = objname + "." + name + '[' + i + ']';
                else fullSubName = name + '[' + i + ']';
                innerObj = {};
                innerObj[fullSubName] = subValue;
                query += requestParam(innerObj) + '&';
            }
        }
        else if(value instanceof Object) {
            for(subName in value) {
                subValue = value[subName];
                //fullSubName = name + '[' + subName + ']';
                if(objname != undefined) fullSubName = objname + "." + name + '.' + subName;
                else fullSubName = name + '.' + subName;
                innerObj = {};
                innerObj[fullSubName] = subValue;
                query += requestParam(innerObj) + '&';
            }
        }
        else if(value !== undefined && value !== null) {
            if(objname != undefined) query += encodeURIComponent(objname + '.' + name) + '=' + encodeURIComponent(value) + '&';
            else query += encodeURIComponent(name) + '=' + encodeURIComponent(value) + '&';
        }

    }

    return query.length ? query.substr(0, query.length - 1) : query;
};

//获取当前时间，格式YYYY-MM-DD
var getNowFormatDate = function () {
    var date = new Date();
    var seperator1 = "-";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = year + seperator1 + month + seperator1 + strDate;
    return currentdate;
}